import React, { Component } from 'react'
import axios from 'axios'
import './index.css'
import Search from './Search'
import List from './List'
export default class AxiosTest extends Component {

  state = { //初始化状态
    users: [], //users初始值为数组
    isFirst: true, //是否为第一次打开页面
    isLoading: false,//标识是否处于加载中
    err: '',//存储请求相关的错误信息
  }
  getStudentData = () => {
    axios.get('/api/students').then(
      response => { console.log(response.data) },
      error => { console.log(error) }
    )
  }
  updateAppState = state => {
    this.setState(state)
  }

  render() {
    return (
      <div>
        {/* <button onClick={this.getStudentData}>调用服务</button> */}
        <div className="container">
          <Search updateAppState={this.updateAppState} />
          <List {...this.state} />
        </div>
      </div>
    )
  }
}
